package com.yjdb.sanyuantang.generator;


import com.yjdb.sanyuantang.generator.source.Generator;
import com.yjdb.sanyuantang.generator.source.DataBaseEntity;
import com.yjdb.sanyuantang.generator.source.YamlReader;

public class MybatisPlusGenerator {


    private static final String CLASS_PATH_Entity = "/com/yjdb/sanyuantang/common/entity";
    private static final String CLASS_PATH_Repository = "/com/yjdb/sanyuantang/common/mapper";

    public static void main(String[] args) {
        YamlReader yamlReader = new YamlReader();
        DataBaseEntity dataBaseEntity = yamlReader.getDatabase();
        // 获取数据库连接地址
        String url = dataBaseEntity.getUrl();
        String username = dataBaseEntity.getUsername();
        String password = dataBaseEntity.getPassword();

        Generator generator = new Generator
                .Builder(url, username, password) // 1.数据库连接地址 2.数据库用户名 3.数据库密码
                .setOpenapi("3")   // 3.openapi3的注解 2.openapi2的注解(尚未开发完成)
                .setEntityAddress(CLASS_PATH_Entity)  // 实体类地址
                .setRpositoryAddress(CLASS_PATH_Repository) // mapper地址
                .setTableName("*") // 表名如果为*则生成所有表
                .build();
        generator.exec();
    }
}
